//
//  GGBaseInfoData.m
//  GGDFU
//
//  Created by 陈志勇 on 17/2/18.
//  Copyright © 2017年 陈志勇. All rights reserved.
//

#import "GGBaseInfoData.h"

@implementation GGBaseInfoData

// 引导握手
//- (NSData *)handShakeWithPacketIndex:(NSUInteger)packetIndex
//                     commandType:(GGBaseInfoDataCommandTpye)commandType
//                      infoLength:(NSUInteger)infoLength
//                        infoData:(NSData *)infoData{
//    self.packetIndex = packetIndex;
//    self.commandType = commandType;
//    self.infoLength = infoLength;
//    self.infoData = infoData;
//    return [self encodeInfoData];
//}

// 数据块下载

// 下载完成

- (NSData *)encodeInfoData{
    
    NSMutableData *mulData = [NSMutableData data];
    
    // 拼接数据包编号
    NSUInteger packetIndex = self.packetIndex;
    [mulData appendBytes:&packetIndex length:1];
    
    // 拼接数据包命令
    NSUInteger commandType = self.commandType;
    [mulData appendBytes:&commandType length:1];
    
    // 拼接数据包长度
    Byte a[2];
    a[0] = (self.infoLength >> 8) & 0xff;
    a[1] = self.infoLength & 0x00ff;
    [mulData appendBytes:a length:2];
    
    // 拼接数据包
    [mulData appendData:self.infoData];
    
    
    return mulData;
}

@end
